package neusoft.yuejian_11.adapter;

import android.content.Context;
import android.content.Intent;
import android.support.v7.widget.RecyclerView;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;

import com.squareup.picasso.Picasso;

import java.util.List;

import neusoft.yuejian_11.activity.MasterDetailActivity;
import neusoft.yuejian_11.base.BaseListAdapter;
import neusoft.yuejian_11.bean.MasterCollectBean;
import neusoft.yuejian_11.R;
import neusoft.yuejian_11.viewHolder.MasteritemViewHolder;

import static neusoft.yuejian_11.interF.Const.BASE_URI;

/**
 * Created by NEUSOFT on 2017/10/24.
 */

public class MasterCollectAdapter extends BaseListAdapter {
    public MasterCollectAdapter(Context context, List data) {
        super(context, data);
    }

    @Override
    protected RecyclerView.ViewHolder onCreateVH(ViewGroup parent, LayoutInflater layoutInflater, int viewType) {
        View itemView=layoutInflater.inflate(R.layout.item_master_list,parent,false);
        MasteritemViewHolder holder=new MasteritemViewHolder(itemView);
        return holder;
    }

    @Override
    protected void onBindVH(RecyclerView.ViewHolder holder, List data, int position) {
        MasteritemViewHolder masteritemViewHolder=(MasteritemViewHolder) holder;
        final MasterCollectBean masterCollectBean = (MasterCollectBean) data.get(position);
        final  int masterId=masterCollectBean.getPm_id();
        final String masterName =masterCollectBean.getPm_name();
        final  String masterInfo =masterCollectBean.getPm_info();
        final String masterPic = BASE_URI+"professorpic/"+masterCollectBean.getPm_pic();
        Picasso.with(context)
                .load(masterPic)
                .into(masteritemViewHolder.imageView);
        masteritemViewHolder.masterNameView.setText(masterName);
        masteritemViewHolder.masterInfoView.setText(masterInfo);

        masteritemViewHolder.itemView.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View view) {
                Intent intent = new Intent(context, MasterDetailActivity.class);
                intent.putExtra("pm_name",masterName);
                intent.putExtra("pm_id",masterId);
                intent.putExtra("pm_pic",masterPic);
                context.startActivity(intent);
            }
        });

    }


}
